﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex04.Menus.Interfaces
{
    public class ActionItem : MenuItem
    {
        private IAction m_Action;

        public ActionItem()
        {
            m_Action = null;
        }

        public ActionItem(string i_Title, IAction i_Action)
        {
            Title = i_Title;
            Action = i_Action;
        }

        public IAction Action
        {
            get { return m_Action; }
            set { m_Action = value; }
        }

        internal override void DoWhenSelected()
        {
            if (Action == null)
            {
                Console.WriteLine("Item not initalized yet.");
            }
            else
            {
                Action.DoIt();
            }
        }
    }
}